<template>
  <view class="index_container">
    <van-nav-bar title="商家管理" />
    <!-- <view class="top_container">
      <view class="userInfo">
        <view class="left_info">
          <img :src="userinfo.headimg" alt="" class="avatar" />
          <view class="info_box">
            <view class="user_name">{{ userinfo.mch_name }}</view>
          </view>
        </view>
        <view class="right_info">
          <view class="balance">{{ userinfo.balance }}</view>
          <view class="text" @tap="go_withdraw">提现</view>
        </view>
      </view>
    </view> -->

    <!-- menu 区域 -->
    <view class="menu_container">
      <!-- <van-grid column-num="3">
            <van-grid-item icon="photo-o" text="文字" v-for=" (item,index) in menuList " :key="index" />
        </van-grid> -->
      <!-- <van-cell title="商品管理" />
      <view class="menu_box1">
        <view
          class="menu_box"
          v-for="(item, index) in menuList"
          :key="index"
          @tap="go_menu(item)"
        >
          <image :src="item.pic" class="menupic"></image>
          <view class="menutitle">{{ item.title }}</view>
        </view>
      </view>
      <van-cell title="订单查询" />
      <view class="menu_box1">
        <view
          class="menu_box"
          v-for="(item, index) in menuList1"
          :key="index"
          @tap="go_menu(item)"
        >
          <image :src="item.pic" class="menupic"></image>
          <view class="menutitle">{{ item.title }}</view>
        </view>
      </view> -->
      <van-cell title="附近商家" />
      <view class="menu_box1">
        <view
          class="menu_box"
          v-for="(item, index) in menuList2"
          :key="index"
          @tap="go_menu(item)"
        >
          <image :src="item.pic" class="menupic"></image>
          <view class="menutitle">{{ item.title }}</view>
        </view>
      </view>
      <van-cell title="工具" />
      <view class="menu_box1">
        <view
          class="menu_box"
          v-for="(item, index) in menuList3"
          :key="index"
          @tap="go_menu(item)"
        >
          <image :src="item.pic" class="menupic"></image>
          <view class="menutitle">{{ item.title }}</view>
        </view>
      </view>
      <!-- <view
        class="menu_box"
        v-for="(item, index) in menuList"
        :key="index"
        @tap="go_menu(item)"
      >
        <image :src="item.pic" class="menupic"></image>
        <view class="menutitle">{{ item.title }}</view>
      </view> -->
    </view>

    <van-dialog id="van-dialog" />
    <van-toast id="van-toast" />
  </view>
</template>

<script>
import Dialog from "../../wxcomponents/vant/dialog/dialog";
import { logout } from "../../utils/imapi";
// import Toast from '../../wxcomponents/vant/toast/toast'
import { removeData } from "../../utils/storage";
const app = getApp();
export default {
  props: {},
  components: {},
  data() {
    return {
      userinfo: {},
      menuList: [
        {
          pic: "/static/index/query_goods.png",
          title: "商品查询",
          url: "/pages/query_goods/query_goods",
        },
        {
          pic: "/static/index/store_house.png",
          title: "仓库宝贝",
          url: "/pages/store_house/store_house",
        },
        {
          pic: "/static/index/liveplay_goods.png",
          title: "可直播宝贝",
          url: "/pages/live_goods/live_goods",
        },
        {
          pic: "/static/index/product_good.png",
          title: "发布宝贝",
          url: "/pages/product_goods/product_goods",
        },
      ],
      menuList1: [
        {
          pic: "/static/index/orderlist.png",
          title: "订单列表",
          url: "/pages/order_list/order_list",
        },
        {
          pic: "/static/index/orderdetail.png",
          title: "订单详情",
          url: "/pages/order_detail/order_detail",
        },
      ],
      menuList2: [
        // {
        //   pic: "/static/index/bargin_twiter.png",
        //   title: "查询推广产品",
        //   url: "/pages/promotion_goods/promotion_goods",
        // },
        {
          pic: "/static/index/bargin_twiter.png",
          title: "附近砍价审核",
          url: "/pages/near_cutprcie_audit/near_cutprcie_audit",
        },
        // {
        //   pic: "/static/index/bargin_twiter.png",
        //   title: "附近商家砍价",
        //   url: "/pages/near_mch_bargin/near_mch_bargin",
        // },
        // {
        //   pic: "/static/index/bargin_twiter.png",
        //   title: "查询曝光产品",
        //   url: "/pages/out_put/out_put",
        // },
        // {
        //   pic: "/static/index/bargin_twiter.png",
        //   title: "基本信息",
        //   url: "/pages/mch_info/mch_info",
        // },
      ],
      menuList3: [
        // {
        //   pic: "/static/index/bargin_twiter.png",
        //   title: "砍价推客版",
        //   url: "/pages/bargin_twitter/bargin_twitter",
        // },
        // {
        //   pic: "/static/index/bargin_twiter.png",
        //   title: "附近商家砍价",
        //   url: "/pages/near_mch_bargin/near_mch_bargin",
        // },
        // {
        //   pic: "/static/index/bargin_twiter.png",
        //   title: "商家基本信息",
        //   url: "/pages/mch_info/mch_info",
        // },
        { pic: "/static/index/logout.png", title: "退出登录" },
      ],
    };
  },
  computed: {},
  watch: {},
  onLoad() {
  },
  onReady() {},
  onShow() {},
  methods: {
    // 获取商家信息
    go_menu(item) {
      if (item.title == "退出登录") {
        Dialog.confirm({
          message: "确定要退出登录吗?",
        })
          .then(async () => {
            const data = await logout()
            // on confirm
            console.log("111");
            this.$toast.loading("退出登录中...");
            removeData("token");
            setTimeout(() => {
              uni.navigateTo({
                url: "/pages/login/login",
              });
            }, 1000);
          })
          .catch(() => {
            // on cancel
          });
        return;
      }
      if (item.title == "商品查询" && this.userinfo.org_type == "1") {
        uni.navigateTo({
          url: item.url + "?type=near",
        });
        return;
      }
      uni.navigateTo({
        url: item.url,
      });
    },
    go_withdraw(item) {
      uni.navigateTo({
        url: "/pages/withdraw/withdraw",
      });
    },
  },
  onReachBottom() {},
  onHide() {},
};
</script>

<style scoped lang="scss" scoped>
.top_container {
  padding: 40upx 32upx 0;
  margin-bottom: 24upx;
}

.avatar {
  width: 112upx;
  height: 112upx;
  margin-right: 20upx;
  border-radius: 50%;
}
.userInfo {
  display: flex;
  justify-content: space-between;
  align-items: center;
  .left_info {
    display: flex;
    align-items: center;
    .info_box {
      .user_name {
        font-size: 36upx;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #0a0819;
        // margin-bottom: 26upx;
      }
    }
  }
  .right_info {
    .balance {
      font-size: 36upx;
      font-family: DINPro-Medium, DINPro;
      font-weight: 500;
      color: #0a0819;
      text-align: right;
      // margin-bottom: 31upx;
    }
    .text {
      width: 128upx;
      height: 44upx;
      border-radius: 22upx;
      border: 1px solid #f95a4b;

      font-size: 28upx;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;

      color: #f95a4b;
      text-align: center;
      line-height: 44upx;
    }
  }
}
.menu_box1 {
  display: flex;
  flex-wrap: wrap;
  border-top: 2upx solid #f0eefd;
  border-bottom: 2upx solid #f0eefd;
  .menu_box {
    width: 187.5upx;
    height: 187.5upx;
    border-right: 2upx solid #f0eefd;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    .menupic {
      width: 60upx;
      height: 60upx;
      margin-bottom: 22upx;
    }
    .menutitle {
      font-size: 28upx;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #0a0819;
    }
  }
}
</style>
